
<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="pdepartmenting-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.keyword" placeholder="关键字"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="search">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>
		<!--列表-->
		<el-table :data=" logs" highlight-current-row v-loading="listLoading" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="operator" label="操作用户" width="150" sortable>
			</el-table-column>
			<el-table-column prop="des" label="具体描述" width="150" sortable>
			</el-table-column>
			<el-table-column prop="meth" label="调用方法" width="200" sortable>
			</el-table-column>
			<el-table-column prop="ip" label="IP地址" width="150" sortable>
			</el-table-column>
			<el-table-column prop="createDate" label="发生时间" width="200" sortable>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="prev, pager, next"
						   @current-change="handleCurrentChange"
						   :current-page="currentPage"
						   :page-size="pageSize"
						   :total="total"
						   style="float:right;">
			</el-pagination>
		</el-col>
	</section>
</template>

<script>
    export default {
        data() {
            return {
                title:"",
                filters: {
                    keyword: ''
                },
                logs:[],//系统日志管理
                total: 0,
                currentPage:1,
                pageSize: 4,
                listLoading: false,

            }
        },
        methods: {
            handleCurrentChange(val) {
                this.currentPage = val;
                this.getLogs();
            },
			search(){
              this.currentPage=1;
              this.getLogs();
			},
            //获取员工列表
            getLogs(){
                this.$http.get("/log")
                    .then(result=>{
                        this.logs=result.data;
                    })
                    .catch(result=>{
                        this.$message({
                            message: '操作失败！',
                            type: 'error'
                        });
                    })
            },
            //获取部门列表
            getLogs() {
                let para = {//请求参数
                    currentPage: this.currentPage,
                    pageSize: this.pageSize,
                    keyword: this.filters.keyword
                };
                this.listLoading = true;//开启忙等框
                //这里发送axios请求从后端拿数据
                this.$http.post("/log",para)
                    .then(result=>{
                        this.listLoading = false;//关闭忙等框
                        result = result.data;//PageList
                        this.logs = result.data;
                        this.total = result.total;

                    })
                    .catch(result=>{
                        this.$message({
                            message: '操作失败！',
                            type: 'error'
                        });
                    })

            },
        },
        mounted() {
            //获取员工列表
            this.getLogs();

        }
    }

</script>

<style scoped>

</style>